package com.example.langchain4j.service;

import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

@Service
public class StreamResponseService implements StreamResponse {
    @Override
    public Flux<String> processStream(String initialData) {
        return Flux.create(emitter -> {
            // 模拟数据流的处理过程
            for (int i = 0; i < 10; i++) {
                // 假设这是从 LangChain 接收到的数据
                String data = "Data " + (i + 1) + " from LangChain";
                emitter.next(data); // 发送数据到订阅者
            }
            emitter.complete(); // 完成流
        });
    }
}
